<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>ajax_get请求</title>
	</head>
	<body>
		<h2>该页面练习：原生ajax-get请求-携带参数</h2>
		<button onclick="sum()">求和</button>

		<script type="text/javascript" >
			function sum(){
				//创建xhr
				const xhr = new XMLHttpRequest()
				//绑定监听
				xhr.onreadystatechange = ()=>{
					if(xhr.readyState === 4){
						if(xhr.status >= 200 && xhr.status <= 299){
							console.log(xhr.response)
						}
					}
				}
				
				//指定发送请求的：方式、地址、query参数(urlencoded)
				// xhr.open('GET','http://127.0.0.1:5000/increment?n1=1&n2=99')

				//指定发送请求的：方式、地址、params参数
				xhr.open('GET','http://127.0.0.1:5000/increment/1/99')
				
				//发送该请求
				xhr.send()
			}
		</script>
	</body>
</html>